import request from './common'
import { encrypt } from '@/utils/rsaEncrypt'
import type { IUserLogin, IAuthRes, IUserInfo } from '@/types'
import { RouteRecordRaw } from 'vue-router'

export function auth (formInfo: IUserLogin) {
  return request.setPath('/auth/login').post<IAuthRes>({ ...formInfo, password: encrypt(formInfo.password!) })
}

export function info () {
  return request.setPath('/auth/info').get<IUserInfo>()
}

export function buildMenu () {
  return request.setPath('/api/menus/build').get<RouteRecordRaw[]>()
}
